﻿<UserControl x:Class="SourceControlMonitor.Views.NotifyBalloonView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:tb="http://www.hardcodet.net/taskbar"
             xmlns:local="clr-namespace:AttachedCommandBehavior;assembly=Infrastructure" x:Name="me"
             Height="130"
             Width="250">
	<UserControl.Resources>
		<Storyboard x:Key="FadeIn">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
				<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.95"/>
				<SplineDoubleKeyFrame KeyTime="00:00:03" Value="0.95"/>
<!--				<SplineDoubleKeyFrame KeyTime="00:00:05" Value="0"/>-->
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Key="HighlightCloseButton">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgClose" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.4"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Key="FadeCloseButton">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="imgClose" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.4"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Key="FadeBack">
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="1"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Storyboard x:Key="FadeOut" Completed="OnFadeOutCompleted" >
			<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
				<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
				<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0.2"/>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
	</UserControl.Resources>
	<UserControl.Triggers>
		<!--<EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonShowing">
			<BeginStoryboard Storyboard="{StaticResource FadeIn}" x:Name="FadeIn_BeginStoryboard"/>
		</EventTrigger>-->
		<EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="imgClose">
			<BeginStoryboard Storyboard="{StaticResource HighlightCloseButton}" x:Name="HighlightCloseButton_BeginStoryboard"/>
		</EventTrigger>
		<EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="imgClose">
			<BeginStoryboard Storyboard="{StaticResource FadeCloseButton}" x:Name="FadeCloseButton_BeginStoryboard"/>
		</EventTrigger>
        <!--<EventTrigger RoutedEvent="Mouse.MouseEnter">
			<StopStoryboard BeginStoryboardName="FadeIn_BeginStoryboard"/>
			<BeginStoryboard x:Name="FadeBack_BeginStoryboard1" Storyboard="{StaticResource FadeBack}"/>
		</EventTrigger>-->
		<EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonClosing">
			<BeginStoryboard Storyboard="{StaticResource FadeOut}" x:Name="FadeOut_BeginStoryboard"/>
		</EventTrigger>
	</UserControl.Triggers>
    <Grid MouseDown="OnMouseDown">
        <Grid x:Name="grid" MouseEnter="OnMouseEnter" local:CommandBehavior.Event="MouseLeftButtonDown" 
              local:CommandBehavior.Command="{Binding OnMouseDown}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <!--<local:CommandBehaviorCollection.Behaviors>
                <local:BehaviorBinding Event="MouseDown" local:CommandBehavior.Command="{Binding OnMouseDown}"/>
                <local:BehaviorBinding Event="MouseRightButtonDown" local:CommandBehavior.Command="{Binding OnRightMouseDown}"/>
            </local:CommandBehaviorCollection.Behaviors>-->
            <Border Grid.RowSpan="3" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Margin="5,5,5,5" BorderThickness="1,1,1,1" BorderBrush="#FF997137">
                <Border.Effect>
                    <DropShadowEffect Color="#FF747474"/>
                </Border.Effect>
                <Border.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="Black" Offset="0" />
                        <GradientStop Color="#FF4B4B4B" Offset="2" />
                    </LinearGradientBrush>
                </Border.Background>
            </Border>
            <Image HorizontalAlignment="Left" Margin="10,10,0,0" Source="../Resources/SourceControlMonitor.ico" Stretch="Uniform" Height="36" VerticalAlignment="Top" />
            <TextBlock VerticalAlignment="Top" Margin="10,10,5,0" Text="{Binding Path=BalloonText, ElementName=me, Mode=Default, FallbackValue='this is an example of a really really long long long long long title'}" Grid.Column="1"
                   TextWrapping="Wrap" Foreground="WhiteSmoke" FontWeight="Bold" TextTrimming="WordEllipsis"/>
            <Path Fill="#FFFFFFFF" Margin="10,0,10,0" Grid.ColumnSpan="2" Grid.Row="1" Stretch="Fill" VerticalAlignment="Top" Height="1" Data="M26,107 L220.04123,107" SnapsToDevicePixels="True">
              <Path.Stroke>
                <LinearGradientBrush EndPoint="0.973,0.5" StartPoint="0.005,0.5">
                  <GradientStop Color="#FFECAD25" Offset="1" />
                  <GradientStop Color="#87ECAD25" Offset="0" />
                </LinearGradientBrush>
              </Path.Stroke>
            </Path>
            <TextBlock Margin="10,0,7,0" TextTrimming="WordEllipsis" Grid.ColumnSpan="2" Grid.Row="2" VerticalAlignment="Top" Foreground="WhiteSmoke" TextWrapping="Wrap" Text="{Binding Path=BalloonDetails, ElementName=me, Mode=Default, FallbackValue='this is an example of a really really long long long long long description that just keeps going and going and going and going and going and going and going and going '}" Height="59" />
            <Image HorizontalAlignment="Right" Grid.Column="1" Margin="0,10,10,0" VerticalAlignment="Top" Width="16" Height="16" Source="../Resources/Close.png" Stretch="Fill" 
               Opacity="0.4" ToolTip="Close" x:Name="imgClose" MouseDown="OnMouseDown" />

      </Grid>
  </Grid>
</UserControl>
